﻿//HTML高度更新模拟动画
//fastCSharp.GetTimerShow(Id).Show();
//fastCSharp.GetTimerShow(Id).Hide();
(function(){
var TimerShow=function()
	{
	this.GetArgument(arguments[0],{Id:null,Time:250,Type:'height'});
	this.NextShowFunction=fastCSharp.ThisFunction(this,this.NextShow);
	this.NextHideFunction=fastCSharp.ThisFunction(this,this.NextHide);
	};
(fastCSharp.Functions.TimerShow=TimerShow).Inherit(fastCSharp.BaseFunction,{
End:function()
	{
	if(this.Interval)
		{
		clearTimeout(this.Interval);
		this[this.IsShow?'ShowEnd':'HideEnd']();
		if(this.OnShowed)	this.OnShowed();
		this.Interval=null;
		}
	},
Show:function(OnShowed)
	{
	this.End();
	this.IsShow=1;
	this.OnShowed=OnShowed;
	this.Element=fastCSharp.$Id(this.Id);
	this.Option={
		Position:this.Element.Css('position'),
		Overflow:this.Element.Css('overflow'),
		Height:this.Element.Opacity(0).Css('position','absolute').Display(1).Height(),
		Width:this.Element.Width()
		};
	this.Element.Css(this.Type,'0px').Css('overflow','hidden').Display('block').Opacity(100).Css('position',this.Option.Position);//.Css('margin,padding','0px')
	this.StartTime=new Date().getTime();
	this.Interval=setInterval(this.NextShowFunction,50);
	},
NextShow:function()
	{
	var Time=new Date().getTime()-this.StartTime;
	if(Time<this.Time)	this.Element.Css(this.Type,(this.Type=='height'?this.Option.Height:this.Option.Width)*Time/this.Time+'px');
	else	this.End();
	},
ShowEnd:function()
	{
	this.Element.Display(1).Css('overflow',this.Option.Overflow).Css(this.Type,null);//.Css('margin,padding','')
	},
Hide:function(OnShowed)
	{
	this.End();
	this.IsShow=0;
	this.OnShowed=OnShowed;
	this.Element=fastCSharp.$Id(this.Id).Display('block');
	this.Option={
		Overflow:this.Element.Css('overflow'),
		Height:this.Element.Height(),
		Width:this.Element.Width()
		};
	this.Element.Css('overflow','hidden');//.Css('margin,padding','0px')
	this.StartTime=new Date().getTime();
	this.Interval=setInterval(this.NextHideFunction,50);
	},
NextHide:function()
	{
	var Time=new Date().getTime()-this.StartTime;
	if(Time<this.Time)	this.Element.Css(this.Type,((this.Type=='height'?this.Option.Height:this.Option.Width)*(this.Time-Time)/this.Time)+'px');
	else	this.End();
	},
HideEnd:function()
	{
	this.Element.Display(0).Css('overflow',this.Option.Overflow).Css(this.Type,null);
	}
		});
fastCSharp.TimerShows={};
fastCSharp.GetTimerShow=function(Id)
	{
	var Value=fastCSharp.TimerShows[Id];
	if(Value)	return Value;
	var Element=fastCSharp.$Id(Id);
	if(Element.Count())
		{
		var Parameter=Element.Attribute('TIMERSHOW');
		(Parameter=Parameter?eval('('+Parameter+')'):{}).Id=Id;
		fastCSharp.TimerShows[Id]=Value=new fastCSharp.Functions.TimerShow(Parameter);
		return Value;
		}
	};
})();